<?php
class Dominio extends Zend_Db_Table_Abstract
{
	protected $_name = "dominio";
	protected $_primary = "id_dominio";
	
	protected $_referenceMap = array(
		'Usuario'=> array(
			'columns'		=> array('id_usuario'),
			'refTableClass'	=> 'Usuario',
			'refColumns'    => array('id_usuario')
		),
		'Cliente'=> array(
			'columns'		=> array('id_cliente'),
			'refTableClass'	=> 'Cliente',
			'refColumns'    => array('id_cliente')
		),
		'Plano'=> array(
			'columns'		=> array('id_plano'),
			'refTableClass'	=> 'Plano',
			'refColumns'    => array('id_plano')
		)
	);
	
	public function getPagamentos($id_cliente)
	{
		$select = $this->select()->setIntegrityCheck(false);
		$select->from(array("d"=>"dominio"))
		       ->join(array("c"=>"cliente"),
		                    "d.id_cliente = c.id_cliente")
		       ->join(array("p"=>"pagamento"),
		                    "p.id_dominio = d.id_dominio")
		       ->where("c.id_cliente = ?", $id_cliente);
		       
		$result = $this->fetchAll($select);
		
		return $result;
	}
}